<?php

namespace app\admin\validate\questions;

use think\Validate;

class QuestionCategory extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'ids|标识' => 'require|array',
        'id|参数' => 'require|>:0',
	    'title|分类名称' => 'chsDash|max:10',
        'pid|父级' => 'number'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 定义场景
     * @var []
     */
    protected $scene = [
        'index' => ['title'],
        'delete' => ['id'],
        'destory' => ['ids'],
    ];

    /**
     * 定义新增场景验证
     * @return $this
     */
    public function sceneCreate()
    {
        return $this->only(['title','pid'])
            ->append('title', 'require');
    }

    /**
     * 定义新增场景验证
     * @return $this
     */
    public function sceneUpdate()
    {
        return $this->only(['title','pid'])
            ->append('title', 'require');
    }

}
